From 2aadb2dff2ef03188a27819d26671112e5d8143b Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 28 Nov 2005 08:40:56 +0000 Subject: [PATCH] Implement the conditional use of FlashWindowEx() properly for MSVC 2005-11-28 Tor Lillqvist * gdk/win32/gdkwindow-win32.c (gdk_window_set_urgency_hint): Implement the conditional use of FlashWindowEx() properly for MSVC compilations. The code was confusingly assuming that if compiled with a "new" compiler, it will only be run on "new" Windows versions. We want it to run on "old" versions, too, even if compiled with a "new" compiler. There are two orthogonal issues: whether the compiler defines the necessary API in its headers, and whether it is present at run-time. (#318077) --- ChangeLog | 9 +++++ ChangeLog.pre-2-10 | 9 +++++ gdk/win32/gdkwindow-win32.c | 75 +++++++++++++++++++------------------ 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index e537933dfd..7106a9fecf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2005-11-28 Tor Lillqvist + * gdk/win32/gdkwindow-win32.c (gdk_window_set_urgency_hint): + Implement the conditional use of FlashWindowEx() properly for MSVC + compilations. The code was confusingly assuming that if compiled + with a "new" compiler, it will only be run on "new" Windows + versions. We want it to run on "old" versions, too, even if + compiled with a "new" compiler. There are two orthogonal issues: + whether the compiler defines the necessary API in its headers, and + whether it is present at run-time. (#318077) + * gtk/gtkcalendar.c (gtk_calendar_init): Use GetLocaleInfo() on Windows to get the localized weekday and month names. strftime() in the Microsoft C library returns strings in the default codepage diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e537933dfd..7106a9fecf 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,14 @@ 2005-11-28 Tor Lillqvist + * gdk/win32/gdkwindow-win32.c (gdk_window_set_urgency_hint): + Implement the conditional use of FlashWindowEx() properly for MSVC + compilations. The code was confusingly assuming that if compiled + with a "new" compiler, it will only be run on "new" Windows + versions. We want it to run on "old" versions, too, even if + compiled with a "new" compiler. There are two orthogonal issues: + whether the compiler defines the necessary API in its headers, and + whether it is present at run-time. (#318077) + * gtk/gtkcalendar.c (gtk_calendar_init): Use GetLocaleInfo() on Windows to get the localized weekday and month names. strftime() in the Microsoft C library returns strings in the default codepage diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 799ab68373..580ac1c3f4 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -29,11 +29,32 @@ #include #include +#ifndef _MSC_VER +#define _WIN32_WINNT 0x0500 +#define WINVER _WIN32_WINNT +#endif + #include "gdk.h" #include "gdkprivate-win32.h" #include "gdkinput-win32.h" #if defined(_MSC_VER) && (WINVER < 0x0500) + +typedef struct +{ + UINT cbSize; + HWND hwnd; + DWORD dwFlags; + UINT uCount; + DWORD dwTimeout; +} FLASHWINFO; + +#define FLASHW_STOP 0 +#define FLASHW_CAPTION 1 +#define FLASHW_TRAY 2 +#define FLASHW_ALL (FLASHW_CAPTION|FLASHW_TRAY) +#define FLASHW_TIMER 4 + #define GetAncestor(hwnd,what) _gdk_win32_get_ancestor_parent (hwnd) static HWND @@ -1539,38 +1560,9 @@ void gdk_window_set_urgency_hint (GdkWindow *window, gboolean urgent) { -#if (WINVER >= 0x0500) - FLASHWINFO flashwinfo; - - g_return_if_fail (GDK_IS_WINDOW (window)); - g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD); - - if (GDK_WINDOW_DESTROYED (window)) - return; - - flashwinfo.cbSize = sizeof (flashwinfo); - flashwinfo.hwnd = GDK_WINDOW_HWND (window); - if (urgent) - flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER; - else - flashwinfo.dwFlags = FLASHW_STOP; - flashwinfo.uCount = 0; - flashwinfo.dwTimeout = 0; - - FlashWindowEx (&flashwinfo); -#else - struct _FLASHWINDOW - { - UINT cbSize; - HWND hwnd; - DWORD dwFlags; - UINT uCount; - DWORD dwTimeout; - } flashwindow = { sizeof (flashwindow), GDK_WINDOW_HWND (window), urgent ? 0x07 : 0x0, 0, 0 }; - typedef BOOL (*PFN_FlashWindowEx) (struct _FLASHWINDOW); + typedef BOOL (*PFN_FlashWindowEx) (FLASHWINFO*); PFN_FlashWindowEx flashWindowEx = NULL; - gboolean once = TRUE; g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD); @@ -1578,16 +1570,25 @@ gdk_window_set_urgency_hint (GdkWindow *window, if (GDK_WINDOW_DESTROYED (window)) return; - if (once) + flashWindowEx = (PFN_FlashWindowEx) GetProcAddress (GetModuleHandle ("user32.dll"), "FlashWindowEx"); + + if (flashWindowEx) { - flashWindowEx = (PFN_FlashWindowEx)GetProcAddress (GetModuleHandle ("user32.dll"), "FlashWindowEx"); - once = FALSE; + flashwinfo.cbSize = sizeof (flashwinfo); + flashwinfo.hwnd = GDK_WINDOW_HWND (window); + if (urgent) + flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER; + else + flashwinfo.dwFlags = FLASHW_STOP; + flashwinfo.uCount = 0; + flashwinfo.dwTimeout = 0; + + flashWindowEx (&flashwinfo); } - if (flashWindowEx) - flashWindowEx(flashwindow); else - FlashWindow (GDK_WINDOW_HWND (window), urgent); -#endif + { + FlashWindow (GDK_WINDOW_HWND (window), urgent); + } } static void -- 2.30.2